package cn.jcet.mapreduce.sort;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @author 鲜磊
 * @Date 2020/12/11 22:54
 */
public class ProvincePartitioner extends Partitioner<FlowBean,Text> {
    @Override
    public int getPartition(FlowBean key,Text value,  int i) {

        // 获取手机号的前三位
        String preNum = value.toString().substring(0, 3);
        // 总分区数量
        int partitioner = 4;
        // 分区判断
        if ("136".equals(preNum)){
            partitioner = 0;
        }else if ("137".equals(preNum)){
            partitioner = 1;
        }else if ("138".equals(preNum)){
            partitioner = 2;
        }else if ("139".equals(preNum)){
            partitioner = 3;
        }
        return partitioner;
    }
}
